import React, { useEffect } from 'react';
import { useLocation, useHistory } from 'react-router-dom';

const DesignPage: React.FC = () => {
  const location = useLocation();
  const history = useHistory();

  useEffect(() => {
    // 从 URL 参数中获取 token
    const params = new URLSearchParams(location.search);
    const token = params.get('token');
    
    if (token) {
      // 保存 token
      localStorage.setItem('token', token);
      // 清除 URL 中的 token
      window.history.replaceState({}, document.title, '/design');
    } else {
      // 检查是否已登录
      const storedToken = localStorage.getItem('token');
      if (!storedToken) {
        history.push('/login');
      }
    }
  }, [location, history]);

  return (
    <div className="min-h-screen bg-gray-100">
      <div className="max-w-7xl mx-auto py-6 sm:px-6 lg:px-8">
        <h1 className="text-3xl font-bold text-gray-900">Design Page</h1>
        {/* 这里添加你的设计页面内容 */}
      </div>
    </div>
  );
};

export default DesignPage; 